package meal;
import java.util.*;
import java.io.*;

//Margarita Lee:mleeli | Last Updated: 10.29.11 -Create the MealFormatting method that formats the meal.

public class MealFormatting{
	//Margarita Lee:mleeli | Last Updated:10.29.11
	//Task: Start of constructor method.
	/**
	* Takes the respective meal name, rating, ingredients and directions and formats it in a
	* more organized way.
	*/
	public static String formatMeal(Meal meal){
		String str = "Name: " + meal.getName()  +"\t" + "Rating: " +
		meal.getRating()+"\nIngredients:\n";

		for(Ingredient ingr: meal.getIngredients()){
			// str+= formated ingredient
			if(ingr.getUnits() == null){
				str+= " " + ingr.getQuantity() +" " + ingr.getName() + "\n";
			}
			else{
				str+= " " + ingr.getQuantity() + " " + ingr.getUnits() + " " + ingr.getName() + "\n";
			}
		}
		str+="\nDirections:\n";
		Direction[] dir = meal.getDirections();
		for(int i = 0; i < dir.length; i++){
		  str+= " " + (i+1) + ". " + dir[i] + "\n";
			// str+= formated direction
		}
		return str;
	}
	//End of the constructor method.
}
